<template>
  <view
    class="content ba_img"
    :style="{
      'padding-top': height + 'px',
    }"
  >
    <view
      :style="{
        height: statusBarHeight + 'px',
      }"
    >
    </view>
    <view
      class="head"
      :style="{
        top: statusBarHeight + 'px',
      }"
    >
      <view class="head_left">
        <u-icon
          name="arrow-left"
          color="#eeeeee"
          size="24"
          :bold="true"
          @click="toBack"
        ></u-icon>
      </view>
      <view class="text">人物志</view>
    </view>
    <view class="box_head_search">
      <view class="box_head">
        <view class="head_location" @click="show = true">
          <!-- 按地点 -->
          {{ location }}
          <u-icon
            name="arrow-down"
            color="#ADADAD"
            style="margin-left: 12rpx"
          ></u-icon>
        </view>
        <view class="head_search">
          <u--input
            place
            holder="搜索感兴趣的问题"
            border="none"
            placeholderStyle="font-size:30rpx;color:#ADADAD;"
            prefixIcon="search"
            prefixIconStyle="font-size: 42rpx;color: #ADADAD"
            color="#ADADAD"
            v-model="value"
            @change="change"
            inputAlign="left"
            @confirm="confirm"
          ></u--input>
        </view>
      </view>
    </view>
    <scroll-view
      :style="{
        height: scrollHeihgt + 'px',
        paddingTop:'20rpx',
        'box-sizing':'border-box'
      }"
      :scroll-y="true"
    >
      <view class="boxs">
        <characterLog
          bgColor="rgba(39,39,39,0.5)"
          :list="list"
          titleColor="#eeeeee"
          textColor="#ADADAD"
		  :search="value"
		  :type="type"
        ></characterLog>
        <view class="boxs-text"> 没有更多了 </view>
        <view :style="{ height: '100rpx' }"></view>
      </view>
    </scroll-view>

    <u-action-sheet
      :actions="locationList"
      cancelText="取消"
      @select="selectClick"
      :show="show"
      @close="show = false"
    ></u-action-sheet>
	<floatingBall></floatingBall>
  </view>
</template>

<script>
import characterLog from "@/components/characterLog.vue"; //人物志
import { getList } from "@/common/api/renwu.js";
export default {
  components: {
    characterLog,
  },
  data() {
    return {
      statusBarHeight: 0,
      height: 0,
      value: "",
      show: false,
      type: 1,
      scrollHeihgt: 0,
      list: [],
      location: "按地点",
      locationList: [
        {
          name: "按地点",
          value: 1,
        },
        {
          name: "按景点",
          value: 2,
        },
        {
          name: "按身份",
          value: 3,
        },
        {
          name: "按纲要",
          value: 4,
        },
      ],
    };
  },
  created() {
    const statusBarHeight = uni.getSystemInfoSync(); // 获取手机状态栏高度
    this.statusBarHeight = statusBarHeight.statusBarHeight;
    const windowHeihgt = statusBarHeight.windowHeight;
    this.$nextTick(() => {
      uni
        .createSelectorQuery()
        .select(".head")
        .boundingClientRect((data) => {
          this.height = data.height;
          // this.windowHeihgt = statusBarHeight.windowHeight - data.height - this.statusBarHeight;
        })
        .exec();
    });

    this.$nextTick(() => {
      const query = uni.createSelectorQuery().in(this);
      query.select(".head").fields({
        size: true,
      });
      query.select(".box_head_search").fields({
        size: true,
      });

      query.exec((data) => {
        let sum = 0;
        data.forEach((item) => {
          sum += item.height;
        });
        this.scrollHeihgt = windowHeihgt - sum;
      });
    });
  },
  onLoad() {
    this.getList();
  },
  methods: {
    toBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    getList() {
      getList({
        type: this.type,
        search: this.value,
      }).then((res) => {
        this.list = res.data.list;
        console.log("rssssssss", res);
      });
    },
    confirm() {
      this.getList();
    },
    change() {
      this.getList();
    },
    selectClick(e) {
      console.log("eeeeee", e);
      this.type = e.value;
      this.location = e.name;
      this.getList();
      this.show = false;
    },
  },
};
</script>

<style scoped lang="scss">
.ba_img {
  position: fixed;
  margin: 0;
  background: url("/static/images/index.png") no-repeat;
  background-size: 100% 100%;
  background-attachment: fixed;
  box-sizing: border-box;
}

.head {
  width: 100%;
  padding: 18rpx 0 47rpx;
  position: fixed;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99;

  .head_left {
    position: absolute;
    left: 30rpx;
  }

  .text {
    font-size: 36rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: 400;
    color: #eeeeee;
  }
}
.box_head_search {
  padding: 0 30rpx;
  box-sizing: border-box;
}
.box_head {
  width: 100%;
  display: flex;
  .head_location {
    width: 204rpx;
    height: 80rpx;
    background: rgba(39, 39, 39, 0.5);
    border-radius: 40rpx 40rpx 40rpx 40rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30rpx;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    color: #eeeeee;
  }

  .head_search {
    width: 460rpx;
    height: 80rpx;
    background: rgba(39, 44, 41, 0.5);
    border-radius: 40rpx 40rpx 40rpx 40rpx;
    display: flex;
    align-items: center;
    padding: 0 32rpx;
    box-sizing: border-box;
    margin-left: 16rpx;
  }
}
.boxs {
  width: 100%;
  padding: 0 30rpx;
  box-sizing: border-box;

  .boxs-text {
    font-size: 26rpx;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    color: #adadad;
    display: flex;
    justify-content: center;
  }
}
</style>